package com.doge.controller.admin;

import com.doge.bean.base.BaseRespVo;
import com.doge.bean.bo.brand.BrandDeleteBo;
import com.doge.bean.pojo.category.Category;
import com.doge.bean.vo.category.CategoryCreateVo;
import com.doge.bean.vo.category.CategoryListVo;
import com.doge.bean.vo.category.CategoryResultL1;
import com.doge.service.admin.category.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: doge
 * @description: 商品类目
 * @author: Mr.Jiang
 * @create: 2021-11-30 16:44
 **/
@RestController
@RequestMapping("admin/category")
public class CategoryController {
    @Autowired
    CategoryService categoryService;

    @RequestMapping("list")
    public BaseRespVo list(){
        CategoryListVo categoryListVo=categoryService.list();
        return BaseRespVo.ok(categoryListVo);
    }


    @RequestMapping("l1")
    public BaseRespVo listl1(){
        CategoryResultL1 categoryResultL1=categoryService.L1();
        return BaseRespVo.ok(categoryResultL1);
    }

    @RequestMapping("create")
    public  BaseRespVo create(@RequestBody Category category){
        CategoryCreateVo categoryCreateVo=categoryService.create(category);
        return BaseRespVo.ok(categoryCreateVo);
    }

    @RequestMapping("update")
    public BaseRespVo update(@RequestBody Category category){
        categoryService.update(category);
        return BaseRespVo.ok();
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody BrandDeleteBo brandDeleteBo){
        categoryService.delete(brandDeleteBo.getId());
        return BaseRespVo.ok();
    }
}
